/*
* @Author: chenggh
* @Date: 2025-06-20
* @Link to Problem : https://webvpn.neu.edu.cn/https/62304135386136393339346365373340bfebea318fd008d8f60d257088/courses/27/part/222/problem/1003
*/
#include <iostream>
#include <vector>
// 维护最优递增子序列
#include <set> // 红黑树解决多次排序

using namespace std;
multiset<int> s; // set会去重，我忘记了这事情
int main(){
	int n; cin >> n;
	// 初始化
	int temp; cin >> temp;
	s.insert(temp);
	int cur_max;
	for(int i = 1; i < n; i++){
		cin >> temp;
		cur_max = *(s.rbegin());
		if(temp >= cur_max){
			s.insert(temp);
			continue;
		}
		auto it = s.upper_bound(temp);
		s.erase(it);
		s.insert(temp);
	}
	cout << s.size() << endl;
	return 0;
}